<script type="text/javascript">
	var supplier_select = "<?=$supplier_select;?>";
	var user_select = "<?=$user_select;?>";
	var contact_select = "<?=$contact_select;?>";
</script>

<h2><a href="<?=site_url('company/'.$company->company_name);?>"><?=$company->company_name;?></a> &ndash; <?=$job->job_title;?></h2>


<input type="hidden" name="jobid" id="jobid" value="<?=$job->id;?>" />
<input type="hidden" name="companyid" id="companyid" value="<?=$company->id;?>" />

<div class="block tabs spaces">
	<div class="hd">
		<ul>
			<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/updates');?>">Updates</a></li>
			<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/milestones');?>">Milestones</a></li>
			<li><a>Costs</a></li>
			<?php if ($permissions->createinvoice):?><li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/billing');?>">Billing</a></li><?php endif;?>
				<li><a href="<?=site_url('company/'.$company->company_name.'/'.$job->job_title.'/setup');?>">Job Setup</a></li>
		</ul>
		<div class="clear"></div>
	</div>

	<div class="bd">


	<?php if ($costs):?>
		<div class="cost">
			<table width="100%" class="projects">
				<thead>
					<tr>
						<td>Cost</td>
						<td>Ref.</td>
						<td>Supplier</td>
						<td>Incomming</td>
						<td>Outgoing</td>
						<td>Delete</td>
					</tr>
				</thead>
				<tbody>
				<?php foreach ($costs as $row => $cost):?>
					<tr>
						<td><span class="edit_textinput" id="<?=$cost->id;?>|cost|cost_title"><?=$cost->cost_title;?></span></td>
						<td><span class="edit_textinput" id="<?=$cost->id;?>|cost|quote_ref"><?=$cost->quote_ref;?></span></td>
						<td><span class="edit_supplierselect" id="<?=$cost->id;?>|cost|supplierid|company|company_name"></td>
						<td><span class="edit_textinput" id="<?=$cost->id;?>|cost|incoming_cost"><?=$cost->incoming_cost;?></span></td>
						<td><span class="edit_textinput" id="<?=$cost->id;?>|cost|outgoing_cost"><?=$cost->outgoing_cost;?></span></td>
						<td><a href="<?=site_url('jobs/deleteCost/'.$cost->id);?>" class="">Delete</a></td>
					</tr>
				<?php endforeach;?>
				</tbody>
			</table>
		</div>
	<?php endif;?>
	</div>
</div>
</div></div></div>

<div id="sidebar" class="yui-b">
	
<div class="block">
	<div class="hd">
		<h3>Add a Supplier Cost</h3>
	</div>
	<div class="bd">
		<?php if ($permissions->addcosts):?>
		<?=form_open('jobs/addCost/', array('class' => 'addCost'));?>
			
		<fieldset>
			<p>
				<label>Title</label>
				<input class="text" type="text" name="cost_title" id="cost_title" />
			</p>
			
			<p>
				<label>Description</label>
				<textarea class="text" rows="10" name="cost_description" id="cost_description"></textarea>
			</p>
			
			<p>
				<label>Quote Ref.</label>
				<input class="text" type="text" name="quote_ref" id="quote_ref" />
			</p>
			
			<p>
				<label>Supplier</label>

				<select class="text" id="supplierid" name="supplierid">
					<option value="0">Internal</option>
					<?php if ($suppliers):?>
					<?php foreach ($suppliers as $supplier):?>
						<option value="<?=$supplier->id;?>"><?=$supplier->company_name;?></option>
					<?php endforeach;?>
					<?php endif;?>		
				</select>
			</p>
			
			<p>
				<label>Incoming Cost</label>
				<input class="text" type="text" name="incoming_cost" id="incoming_cost" class="cost" />
			</p>
			
			<p>
				<label>Outgoing Cost</label>
				<input class="text" type="text" name="outgoing_cost" id="outgoing_cost" class="cost" />
			</p>
		</fieldset>
			
		<input type="hidden" class="hidden" name="jobid" value="<?=$job->id;?>" />

		<p><input type="submit" class="submit" value="Save Cost" /></p>

	<?= form_close();?>
	<?php endif;?>
	</div>
</div>